/*
 * Copyright (C) 2008 TranceCode Software
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 * 
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
 *
 * $Id$
 */
package org.trancecode.rdf;

import com.google.common.base.Function;


/**
 * {@link Function} implementations related to {@link Triple}.
 * 
 * @author Herve Quiroz
 * @version $Revision: 3842 $
 */
public final class TripleFunctions
{
	private TripleFunctions()
	{
		// No instantiation
	}


	public Function<String, UriReference> toUriReference()
	{
		return StringToUriReferenceFunction.INSTANCE;
	}


	private static class StringToUriReferenceFunction implements Function<String, UriReference>
	{
		public static final StringToUriReferenceFunction INSTANCE = new StringToUriReferenceFunction();


		private StringToUriReferenceFunction()
		{
			// Singleton
		}


		@Override
		public UriReference apply(final String string)
		{
			// TODO
			return null;
		}
	}


	public static Function<Triple, Reference> subject()
	{
		return SubjectFunction.INSTANCE;
	}


	private static class SubjectFunction implements Function<Triple, Reference>
	{
		public static final SubjectFunction INSTANCE = new SubjectFunction();


		private SubjectFunction()
		{
			// Singleton
		}


		@Override
		public Reference apply(final Triple triple)
		{
			return triple.subject();
		}
	}


	public static Function<Triple, Value> object()
	{
		return ObjectFunction.INSTANCE;
	}


	private static class ObjectFunction implements Function<Triple, Value>
	{
		public static final ObjectFunction INSTANCE = new ObjectFunction();


		private ObjectFunction()
		{
			// Singleton
		}


		@Override
		public Value apply(final Triple triple)
		{
			return triple.object();
		}
	}


	public static Function<Triple, UriReference> predicate()
	{
		return PredicateFunction.INSTANCE;
	}


	private static class PredicateFunction implements Function<Triple, UriReference>
	{
		public static final PredicateFunction INSTANCE = new PredicateFunction();


		private PredicateFunction()
		{
			// Singleton
		}


		@Override
		public UriReference apply(final Triple triple)
		{
			return triple.predicate();
		}
	}


	public static Function<Triple, UriReference> reference()
	{
		return ReferenceFunction.INSTANCE;
	}


	private static class ReferenceFunction implements Function<Triple, UriReference>
	{
		public static final ReferenceFunction INSTANCE = new ReferenceFunction();


		private ReferenceFunction()
		{
			// Singleton
		}


		@Override
		public UriReference apply(final Triple triple)
		{
			return triple.reference();
		}
	}
}
